package com.ply.flashsalessystem.entity.status;

import com.ply.flashsalessystem.entity.vo.store.OrderForStoreVo;

import java.util.List;
import java.util.Objects;

/**
 * @author XiaoPan
 * date: 2022/3/27 12:25
 * <p>
 * action:  订单状态
 */
public interface OrderStatus {
    /**
     * 查看 我的 地址的 订单 可分页
     * 0  未付款
     * 1  已付款  (未发货)
     * 2  已发货 (店家未签收) (已分拣)
     * 4  店家已签收  (买家未签收)
     * 5  买家已签收
     * 6  订单异常
     * 7  订单结束  (签收后 两天自动结束订单)
     * 8  订单已取消
     */
    Integer NO_PAY = 0;

    Integer DO_PAY = 1;

//    Integer delivery = 0;
    Integer DELIVERY = 2;

//    Integer STORE_NO_SIGN = 3;

    Integer STORE_DO_SIGN = 4;

    Integer USER_DO_SIGN = 5;

    Integer ORDER_ERROR = 6;

    Integer ORDER_END = 7;

    Integer CANCEL_ORDER = 8;

//    Integer DO_SORT = 8;

    Integer ORDER_MAX = 8;

    static List<OrderForStoreVo> addStatusString(List<OrderForStoreVo> order) {
        if (order == null){
            return null;
        }
        for (OrderForStoreVo orderForStoreVo : order) {
            Integer status = orderForStoreVo.getStatus();
            if (Objects.equals(status, NO_PAY)) {
                orderForStoreVo.setStatusString("未付款");
                continue;
            }

            if (Objects.equals(status, DO_PAY)) {
                orderForStoreVo.setStatusString("已付款");
                continue;
            }

            if (Objects.equals(status, DELIVERY)) {
                orderForStoreVo.setStatusString("已发货");
                continue;
            }

            if (Objects.equals(status, STORE_DO_SIGN)) {
                orderForStoreVo.setStatusString("店家已签收");
                continue;
            }

            if (Objects.equals(status, USER_DO_SIGN)) {
                orderForStoreVo.setStatusString("买家已签收");
                continue;
            }

            if (Objects.equals(status, ORDER_ERROR)) {
                orderForStoreVo.setStatusString("订单异常");
                continue;
            }
            if (Objects.equals(status, ORDER_END)) {
                orderForStoreVo.setStatusString("订单结束");
                continue;
            }
            if (Objects.equals(status, CANCEL_ORDER)) {
                orderForStoreVo.setStatusString("订单已取消");
            }
        }
        return order;
    }
}
